package com.xt.springcloud.service;

import com.xt.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class DeptClientServiceFallBackFactory implements FallbackFactory {
    @Override
    public DeptClientService create(Throwable cause) {
        return new DeptClientService() {
            @Override
            public List<Dept> listDept() {
                List<Dept> list = new ArrayList<>();
                Dept dept = new Dept();
                dept.setId(0);
                dept.setName("客户端提供了降级的信息，这个服务现在已经被关闭");
                list.add(dept);
                return list;
            }
        };
    }
}

